﻿using UnityEngine;

//掉落道具
public class DropItem : MonoBehaviour
{
    private int speed = 10;

    private void Update()
    {
        float dis = Vector3.Distance(transform.position, Mgr.mainPlayer.transform.position);
        if(dis <= 4)
        {
            Move();
        }
        if(dis < 0.7)
        {
            Destroy(gameObject);
            Mgr.bagServerMgr.AddItem(EnumItem.HPDrug);
        }
    }

    private void Move()
    {
        Vector3 point = Mgr.mainPlayer.transform.position;
        point.y = 1;
        Vector3 newPoint = Vector3.MoveTowards(transform.position, point, speed * Time.deltaTime);
        transform.position = newPoint;
        
    }
}